import { NodeStatues } from "../Enum";
import BTNode from "./BTNode";

export default abstract class BTParent extends BTNode{
    children:Array<BTNode>=[];
    private _index=0;
    constructor(children:Array<BTNode>) {
        super();
        this.children=children;
    }

    public get index(){
        return this._index;
    }

    public set index(value:number){
        this._index=value;
    }

    addChild(child:Array<BTNode>){
        this.children=child;
    }
    removeChild(child:BTNode){
        const index=this.children.indexOf(child);
        if(index!==-1){
            this.children.splice(index,1);
        }
    }
    clearChildren(){
        this.children.length=0;
    }

    decorate(statue:NodeStatues){
        return statue;;
    }

    abstract canExecute():boolean;
    abstract onChildExecute(statue: NodeStatues):void;

}